package csu.web.jpetstore.persistence.impl;

import csu.web.jpetstore.domain.Logger;
import csu.web.jpetstore.persistence.DBUtil;
import csu.web.jpetstore.persistence.LoggerDAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class LoggerDAOImpl implements LoggerDAO {

    private static final String sql="INSERT INTO LOGGER (USERNAME,ACTION,STARTTIME) VALUES (?,?,?)";
    public static Logger loginLogger=new Logger();
    @Override
    public void logger(Logger logger) throws SQLException {
        Connection connection=DBUtil.getConnection();
        PreparedStatement preparedStatement=connection.prepareStatement(sql);
        preparedStatement.setString(1,logger.getUsername());
        preparedStatement.setString(2, logger.getAction());
        preparedStatement.setString(3, logger.getStarttime());
        preparedStatement.execute();
    }
}
